import { Injectable, Logger } from '@nestjs/common';
import { CreateCustomerInfoDto } from './dto/create-customer_info.dto';
import { UpdateCustomerInfoDto } from './dto/update-customer_info.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { CancelRule } from '../../rule/canale_rule/entities/canale_rule.entity';
import { Repository } from 'typeorm';
import { CreateCanaleRuleDto } from '../../rule/canale_rule/dto/create-canale_rule.dto';
import { CustomerInfo } from './entities/customer_info.entity';
import { SuccessResponse } from '../../../util/ResultResponse';

@Injectable()
export class CustomerInfoService {
  private readonly logger: Logger = new Logger('CustomerInfoService');

  constructor(
    @InjectRepository(CustomerInfo)
    private readonly customerInfoRepository: Repository<CustomerInfo>,
  ) {}

  create(createCanaleRuleDto: CreateCanaleRuleDto){

  }

  async findAll() : Promise<SuccessResponse<CustomerInfo[]>>  {
    this.logger.log(await this.customerInfoRepository.find());
    return await this.customerInfoRepository.find().then(result => {
      return {
        code: 0,
        data: result,
        message: '成功',
      };
    })
  }

  findOne(id: number) {
    return `This action returns a #${id} customerInfo`;
  }

  update(id: number, updateCustomerInfoDto: UpdateCustomerInfoDto) {
    return `This action updates a #${id} customerInfo`;
  }

  remove(id: number) {
    return `This action removes a #${id} customerInfo`;
  }
}
